﻿using System;
using System.Collections.Generic;
using NetBay.Core.Log;
using Rio.Manager.Business.Repository.Translator;
using NetBay.Core.BusinessEntities.Versioning;
using Rio.Manager.DataAccess;

namespace Rio.Manager.Business.Repository
{
    public class VersioningRepository
    {
        /// <summary>
        /// Add a Versioning model to the specified FolderType
        /// </summary>
        /// <param name="FolderTypeIdentifier">Folder type identifier</param>
        /// <param name="Model"></param>
        public static void SetVersionModel(long FolderTypeIdentifier, VersioningModel Model)
        {
            try
            {
                DA_Versioning.SetVersionModel(FolderTypeIdentifier, Model);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError(ex.Message);
            }
        }

        /// <summary>
        /// Update Versioning model to the specified FolderType identifier
        /// </summary>
        /// <param name="FolderTypeIdentifier"></param>
        /// <param name="Model"></param>
        public static void UpdateVersionModel(VersioningModel Model)
        {
            DA_Versioning.UpdateVersionModel(Model);
        }

        /// <summary>
        /// Get the model of the specified folder type
        /// </summary>
        /// <param name="FolderTypeIdentifier">Folder type identifier</param>
        public static VersioningModel GetVersionModel(long FolderTypeIdentifier)
        {
            return VersioningTranslator.GetVersionModel(DA_Versioning.GetVersionModel(FolderTypeIdentifier));
        }

        /// <summary>
        /// Get version checkout in a foder type
        /// </summary>
        /// <param name="FolderTypeIdentifier">Folder type identifier</param>
        public static List<VersioningItem> GetCheckOutVersionByFolderType(long FolderTypeIdentifier)
        {
            return VersioningTranslator.GetCheckOutVersionByFolderType(DA_Versioning.GetCheckOutVersionByFolderType(FolderTypeIdentifier));
        }

        /// <summary>
        /// Determines whether the specified folder type have document in checkout.
        /// </summary>
        /// <param name="FolderTypeIdentifier">Folder type identifier</param>
        public static Boolean HasCheckoutVersionByFolderType(long FolderTypeIdentifier)
        {
            return VersioningTranslator.HasCheckoutVersionByFolderType(DA_Versioning.HasCheckoutVersionByFolderType(FolderTypeIdentifier));
        }

        /// <summary>
        /// Delete all document version.
        /// </summary>
        /// <param name="p_lFolderTypeId">Folder type identifier</param>
        public static void DeleteAllDocumentVersionByFolderTypeId(long p_lFolderTypeId)
        {
            DA_Versioning.DeleteAllDocumentVersionByFolderTypeId(p_lFolderTypeId);
        }
    }
}